home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Interapplication Communication / MenuScripter 4.0 / Sources / MSAETextUtils.h < prev    next >
Encoding:
Text File  |  1996-07-09  |  3.1 KB  |  91 lines  |  [TEXT/CWIE]

  1. // MSAETextUtils.h
  2. //
  3. // Original version by Jon Lansdell and Nigel Humphreys.
  4. // 4.0 and 3.1 updates by Greg Sutton.
  5. // ©Apple Computer Inc 1996, all rights reserved.
  6.  
  7. #ifndef __MSAETEXTUTILS__
  8. #define __MSAETEXTUTILS__
  9.  
  10. #include "MSToken.h"
  11.  
  12. #include <TextEdit.h>
  13.  
  14. OSErr        PutStyledTextFromDescIntoTEHandle(const AEDesc *sourceTextDesc, TEHandle theHTE);
  15.  
  16. TEHandle    TEHandleFromWindow(WindowPtr theWindow);
  17. TEHandle    TEHandleFromTextToken(TextToken* aToken);
  18.  
  19. OSErr        GetInsertDescFromInsertHere(AEDesc* insertHereDesc,
  20.                                         AEDesc* insertDesc, DescType* insertType);
  21.                                         
  22. enum TokenWithinType
  23. {
  24.     kTokenBefore = 1, kTokenPartialBefore, kTokenWithin,
  25.     kTokenPartialAfter, kTokenAfter
  26. };
  27.  
  28. typedef enum TokenWithinType TokenWithinType;
  29.  
  30. TokenWithinType    TokenWithinToken(TextToken* container, TextToken* token, short* numPartial);
  31.  
  32.                 // Text from window routines
  33.  
  34. OSErr        TextTokenFromDocumentToken(WindowToken* theWindowToken, TextToken* theTextToken);
  35. OSErr        TextTokenFromDocumentDesc(AEDesc* windowDesc, TextToken* aToken);
  36. OSErr        TextDescFromDocumentToken(WindowToken* theWindowToken, AEDesc* textDesc);
  37. OSErr        TextDescFromDocumentDesc(AEDesc* windowDesc, AEDesc* textDesc);
  38.  
  39. typedef char chars[32001];
  40. typedef chars **charsHandle;
  41.  
  42.                 // Routines to count and get desccriptors of text
  43.  
  44. void         MoveToNonSpace(short *start, short limit, charsHandle myChars);
  45. void        MoveToSpace(short *start, short limit, charsHandle myChars);
  46. void        MoveToEndOfParagraph(short *start, short limit, charsHandle myChars);
  47.  
  48. OSErr        CountTextElements(TEHandle inTextHandle, short startAt,
  49.                                 short forHowManyChars, DescType elementType, short* result);
  50. OSErr        GetDescOfNthTextElement(short index, DescType elementType,
  51.                                         TextToken* containerToken, AEDesc* result);
  52.  
  53.                 // Routines to determine text token type
  54.  
  55. char        GetTEHChar(TEHandle aTEH, short offset);
  56.  
  57. Boolean        IsAtStart(TextToken* theToken);
  58. Boolean        IsAtEnd(TextToken* theToken);
  59. Boolean        IsWhiteSpace(short aChar);
  60. Boolean        IsParagraphDelimiter(short aChar);
  61. Boolean        IsContentsToken(TextToken* theToken);
  62. Boolean        IsParagraphToken(TextToken* theToken, short* start, short* end);
  63. Boolean        IsWordToken(TextToken* theToken, short* start, short* end);
  64.  
  65. DescType    GetTextTokenType(TextToken* theToken, short* start, short* end);
  66.  
  67. OSErr        MakeContentsSpecifier(TextToken* theToken, AEDesc* result);
  68. OSErr        MakeAbsoluteTextSpecifier(WindowPtr theWindow, DescType textType, long index, AEDesc* result);
  69. OSErr        MakeInsertionPointSpecifier(TextToken* theToken, AEDesc* result);
  70.  
  71. OSErr        GetIndexSpecifier(TextToken* theToken, DescType textType, long index, AEDesc* result);
  72.  
  73.                 // Call following routine to get a specifier for any given text token
  74.  
  75. OSErr        GetTextTokenObjectSpecifier(TextToken* theToken, AEDesc* result);
  76.  
  77. enum
  78. {
  79.     ETX = 0x03, // Enter key on keyboard or keypad
  80.     BS  = 0x08, // Backspace key on keyboard
  81.     HT  = 0x09, // Tab key on keyboard
  82.     LF    = 0x0A,    // Line feed character
  83.     CR  = 0x0D, // Return key on keyboard
  84.     ESC = 0x1B, // Clear key on keypad
  85.     FS  = 0x1C, // Left arrow key on keypad
  86.     GS  = 0x1D, // Right arrow key on keypad
  87.     RS  = 0x1E, // Up arrow key on keypad
  88.     US  = 0x1F  // Down arrow key on keypad
  89. };
  90.  
  91. #endif